package denseComputiing

/*
    #cgo CFLAGS: -I../
    #cgo LDFLAGS: -L../ -ldecd -lm
	#include "compute.h"
	#include "device.h"
	#include "key.h"
	#include "manager.h"
	#include "xdma.h"
    #include <stdlib.h>
*/
import "C"
import (
	"bytes"
	"encoding/binary"
	"errors"
	"fmt"
	"unsafe"
)

//// 返回指定长度的随机数
//func RndData(randByteLen uint32) (int32, error) {
//	var err error     // 出错返回值
//	var retStr string // 功能返回值
//	var retRanNum int32
//	randData := make([]byte, randByteLen)                     // 给随机数变量申请空间
//	randDataCs := GetCharPointerRand(randData)                // 用CGO语言的字符串功能转换
//	rv := C.NFHE_RndData(randDataCs, C.CK_ULONG(randByteLen)) // 返回随机数
//	if rv != 0 {
//		cw := fmt.Sprintf("%x", rv)
//		err = errors.New("出错信息:NFHE_RndData 生成随机数时出错！错误号：" + cw)
//	} else {
//		retStr = string(randData) // 取出随机数的值，并且返回
//		retStrByte, _ := hex.DecodeString(retStr)
//		retRanNum = BytesToInt32(retStrByte)
//	}
//	return retRanNum, err
//}

//// 将cgo的字节转换为C语言的void指针
//func GetCharPointerRand(val []byte) C.CK_BYTE_PTR {
//	return (C.CK_BYTE_PTR)(unsafe.Pointer(&val[0]))
//}

// ------------------批处理----------------------加密6个接口
// PEnc32Ex 32位无符号批处理加密
func PEnc32Ex(uiKeyIndexs []uint, nCount uint, plainData []uint) ([]byte, error) {
	var err error            // 出错返回值
	var retEncDataStr []byte // 功能返回值
	plainDataTmp := GetUintPointeruint32(plainData)
	keyIndexTmp := GetintPointerint64(uiKeyIndexs)                       //Modify keyIndex
	bt := make([]byte, 16*nCount)                                        // 初始化34 * nCount个字节
	encData := GetBytePointer(bt)                                        // 将cgo的字节转换为c语言的字节类型
	rv := C.PEnc32Ex(C.uint(nCount), plainDataTmp, keyIndexTmp, encData) //加密
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PEnc32Ex 批处理密态计算时出错！错误号：" + cw)
	} else {
		retEncDataStr = bt[0 : 16*nCount] // 取出密文
	}
	return retEncDataStr, err
}

// PEncS32Ex 32位有符号批处理加密
func PEncS32Ex(uiKeyIndexs []uint, nCount uint, plainData []int32) ([]byte, error) {
	var err error            // 出错返回值
	var retEncDataStr []byte // 功能返回值
	plainDataTmp := GetintPointerint32(plainData)
	keyIndexTmp := GetintPointerint64(uiKeyIndexs)
	bt := make([]byte, 16*nCount)                                         // 初始化34 * nCount个字节
	encData := GetBytePointer(bt)                                         // 将cgo的字节转换为c语言的字节类型
	rv := C.PEncS32Ex(C.uint(nCount), plainDataTmp, keyIndexTmp, encData) //加密
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PEncS32Ex 批处理密态计算时出错！错误号：" + cw)
	} else {
		retEncDataStr = bt[0 : 16*nCount] // 取出密文
	}
	return retEncDataStr, err
}

// PEnc64Ex 64位无符号批处理加密
func PEnc64Ex(uiKeyIndexs []uint, nCount uint, plainData []int64) ([]byte, error) {
	var err error            // 出错返回值
	var retEncDataStr []byte // 功能返回值
	plainDataTmp := GetuintPointeruint64(plainData)
	keyIndexTmp := GetintPointerint64(uiKeyIndexs)
	bt := make([]byte, 16*nCount)                                        // 初始化34 * nCount个字节
	encData := GetBytePointer(bt)                                        // 将cgo的字节转换为c语言的字节类型
	rv := C.PEnc64Ex(C.uint(nCount), plainDataTmp, keyIndexTmp, encData) //加密
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PEnc64Ex 批处理密态计算时出错！错误号：" + cw)
	} else {
		retEncDataStr = bt[0 : 16*nCount] // 取出密文
	}
	return retEncDataStr, err
}

// PEncS64Ex 64位有符号批处理加密
func PEncS64Ex(uiKeyIndexs []uint, nCount uint, plainData []uint64) ([]byte, error) {
	var err error            // 出错返回值
	var retEncDataStr []byte // 功能返回值
	plainDataTmp := GetintPointerulong64(plainData)
	keyIndexTmp := GetintPointerint64(uiKeyIndexs)
	bt := make([]byte, 16*nCount)                                         // 初始化34 * nCount个字节
	encData := GetBytePointer(bt)                                         // 将cgo的字节转换为c语言的字节类型
	rv := C.PEncS64Ex(C.uint(nCount), plainDataTmp, keyIndexTmp, encData) //加密
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PEncS64Ex 批处理密态计算时出错！错误号：" + cw)
	} else {
		retEncDataStr = bt[0 : 16*nCount] // 取出密文
	}
	return retEncDataStr, err
}

// PEncF32Ex 32位浮点数批处理加密
func PEncF32Ex(uiKeyIndex []uint, nCount uint, plainData []float32) ([]byte, error) {
	var err error            // 出错返回值
	var retEncDataStr []byte // 功能返回值
	plainDataTmp := GetfloatPointerfloat32(plainData)
	keyIndexTmp := GetintPointerint64(uiKeyIndex)
	bt := make([]byte, 16*nCount)                                         // 初始化34 * nCount个字节
	encData := GetBytePointer(bt)                                         // 将cgo的字节转换为c语言的字节类型
	rv := C.PEncF32Ex(C.uint(nCount), plainDataTmp, keyIndexTmp, encData) //加密
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PEncF32Ex 批处理密态计算时出错！错误号：" + cw)
	} else {
		retEncDataStr = bt[0 : 16*nCount] // 取出密文
	}
	return retEncDataStr, err
}

// PEncF64Ex 64位浮点数批处理加密
func PEncF64Ex(uiKeyIndex []uint, nCount uint, plainData []float64) ([]byte, error) {
	var err error            // 出错返回值
	var retEncDataStr []byte // 功能返回值
	plainDataTmp := GetfloatPointerdouble(plainData)
	keyIndexTmp := GetintPointerint64(uiKeyIndex)
	bt := make([]byte, 16*nCount)                                         // 初始化34 * nCount个字节
	encData := GetBytePointer(bt)                                         // 将cgo的字节转换为c语言的字节类型
	rv := C.PEncF64Ex(C.uint(nCount), plainDataTmp, keyIndexTmp, encData) //加密
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PEncF64Ex 批处理密态计算时出错！错误号：" + cw)
	} else {
		retEncDataStr = bt[0 : 16*nCount] // 取出密文
	}
	return retEncDataStr, err
}

// -------------------批处理---------------------解密1个接口
// PDecEx 批处理解密 PDecEx(CK_ULONG nCount, CK_BYTE_PTR pEncrypteddata, CK_ULONG uiKeyIndex, CK_BYTE_PTR pFhe_Auth, CK_BYTE_PTR pPlaindata, CK_BYTE_PTR pType)
func PDecEx(uiKeyIndex []uint, nCount uint, encData []byte, fheauth string) ([]byte, []byte, error) {
	var err error // 出错返回值

	encDataByte := GetBytePointer(encData)                                            // 将go字符串转换C字符串
	user_auth_pass_word_str := C.CString(fheauth)                                     // 将go字符串转换C字符串
	defer C.free(unsafe.Pointer(user_auth_pass_word_str))                             // 动态回收内存空间
	var user_auth_pass_word_str1 = (*C.char)(unsafe.Pointer(user_auth_pass_word_str)) // 将C字符串转换C.char指针

	keyIndexTmp := GetintPointerint64(uiKeyIndex) // 解密密钥

	Plaindata := make([]byte, nCount*8) // 申请解密后的明文空间
	PlaindataPtr := GetBytePointer(Plaindata)
	Plaindatatype := make([]byte, nCount) // 申请解密后的明文类型空间
	PlaindataTypePtr := GetBytePointer(Plaindatatype)
	rv := C.PDecEx(C.uint(nCount), encDataByte, keyIndexTmp, user_auth_pass_word_str1, PlaindataPtr, PlaindataTypePtr)
	var PlaindataByte []byte
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PDec 密态计算时出错！错误号：" + cw)
	} else {
		PlaindataByte = Plaindata // 取出明文Byte
	}
	return PlaindataByte, Plaindatatype, err
}

//----------------批处理----------------一批密文求和 1个接口
//// PAddEx 批处理求和
//func PSum(nCount uint, encData1 []byte)  ([]byte, error) {
//	var err error // 出错返回值
//	var ret []byte // 功能返回值
//	bt := make([]byte, 16) // 给密态计算的密文赋初值
//	encSumResult := GetBytePointer(bt) // 将字节转换为字符串
//	//fmt.Println(encData1, encData2)
//	rv := C.PSum(C.uint(nCount), GetBytePointer(encData1), encSumResult) //批处理密文求和
//	if rv != 0 {
//		cw := fmt.Sprintf("%x", rv)
//		err = errors.New("出错信息:PAddEx 密态计算时出错！错误号：" + cw)
//	} else {
//		ret = bt[0:16 * nCount] //取出密态计算的结果密文
//		return ret, nil
//	}
//	return ret, err
//}

// ----------------批处理----------------密态计算加减乘除 4个接口
// PAddEx 批处理加法
func PAddEx(nCount uint, encData1 []byte, uiKeyIdx1 []uint, encData2 []byte, uiKeyIdx2 []uint, uiKeyIdx3 []uint) ([]byte, error) {
	var err error        // 出错返回值
	var retEncStr []byte // 功能返回值

	encDataByte1 := GetBytePointer(encData1) // 将go字符串转换C字符串
	encDataByte2 := GetBytePointer(encData2) // 将go字符串转换C字符串
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex2Tmp := GetintPointerint64(uiKeyIdx2)
	keyIndex3Tmp := GetintPointerint64(uiKeyIdx3)
	bt := make([]byte, 16*nCount)                                                                                   // 给密态计算的密文赋初值
	encResult := GetBytePointer(bt)                                                                                 // 将字节转换为字符串
	rv := C.PAddEx(C.uint(nCount), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, encResult, keyIndex3Tmp) //批处理密文加法
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PAddEx 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = bt[0 : 16*nCount] //取出密态计算的结果密文
	}
	return retEncStr, err
}

// PSubEx 批处理减法
func PSubEx(nCount uint, encData1 []byte, uiKeyIdx1 []uint, encData2 []byte, uiKeyIdx2 []uint, uiKeyIdx3 []uint) ([]byte, error) {
	var err error        // 出错返回值
	var retEncStr []byte // 功能返回值

	encDataByte1 := GetBytePointer(encData1) // 将go字符串转换C字符串
	encDataByte2 := GetBytePointer(encData2) // 将go字符串转换C字符串
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex2Tmp := GetintPointerint64(uiKeyIdx2)
	keyIndex3Tmp := GetintPointerint64(uiKeyIdx3)
	bt := make([]byte, 16*nCount)                                                                                   // 给密态计算的密文赋初值
	encResult := GetBytePointer(bt)                                                                                 // 将字节转换为字符串
	rv := C.PSubEx(C.uint(nCount), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, encResult, keyIndex3Tmp) //批处理密文减法
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PSubEx 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = bt[0 : 16*nCount] //取出密态计算的结果密文
	}
	return retEncStr, err
}

// PMulEx 批处理乘法
func PMulEx(nCount uint, encData1 []byte, uiKeyIdx1 []uint, encData2 []byte, uiKeyIdx2 []uint, uiKeyIdx3 []uint) ([]byte, error) {
	var err error        // 出错返回值
	var retEncStr []byte // 功能返回值

	encDataByte1 := GetBytePointer(encData1) // 将go字符串转换C字符串
	encDataByte2 := GetBytePointer(encData2) // 将go字符串转换C字符串
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex2Tmp := GetintPointerint64(uiKeyIdx2)
	keyIndex3Tmp := GetintPointerint64(uiKeyIdx3)
	bt := make([]byte, 16*nCount)                                                                                   // 给密态计算的密文赋初值
	encResult := GetBytePointer(bt)                                                                                 // 将字节转换为字符串
	rv := C.PMulEx(C.uint(nCount), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, encResult, keyIndex3Tmp) //批处理密文乘法
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PMulEx 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = bt[0 : 16*nCount] //取出密态计算的结果密文
	}
	return retEncStr, err
}

// PDivEx 批处理除法
func PDivEx(nCount uint, encData1 []byte, uiKeyIdx1 []uint, encData2 []byte, uiKeyIdx2 []uint, uiKeyIdx3 []uint) ([]byte, error) {
	var err error        // 出错返回值
	var retEncStr []byte // 功能返回值

	encDataByte1 := GetBytePointer(encData1) // 将go字符串转换C字符串
	encDataByte2 := GetBytePointer(encData2) // 将go字符串转换C字符串
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex2Tmp := GetintPointerint64(uiKeyIdx2)
	keyIndex3Tmp := GetintPointerint64(uiKeyIdx3)
	bt := make([]byte, 16*nCount)                                                                                   // 给密态计算的密文赋初值
	encResult := GetBytePointer(bt)                                                                                 // 将字节转换为字符串
	rv := C.PDivEx(C.uint(nCount), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, encResult, keyIndex3Tmp) //批处理密文除法
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PDivEx 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = bt[0 : 16*nCount] //取出密态计算的结果密文
	}
	return retEncStr, err
}

// ------------------批处理--------------密态计算关系运算<、<=、>、>=、==、<> 6个接口
// 批处理密态计算关系运算小于
func PComLTEx(nCount uint, encData1 []byte, uiKeyIdx1 []uint, encData2 []byte, uiKeyIdx2 []uint, uiKeyIdx3 []uint) ([]byte, error) {
	var err error        // 出错返回值
	var retEncStr []byte // 功能返回值

	encDataByte1 := GetBytePointer(encData1) // 将go字符串转换C字符串
	encDataByte2 := GetBytePointer(encData2) // 将go字符串转换C字符串
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex2Tmp := GetintPointerint64(uiKeyIdx2)
	keyIndex3Tmp := GetintPointerint64(uiKeyIdx3)
	bt := make([]byte, 16*nCount)                                                                                     // 给密态计算的密文赋初值
	encResult := GetBytePointer(bt)                                                                                   // 将字节转换为字符串
	rv := C.PComLTEx(C.uint(nCount), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, encResult, keyIndex3Tmp) //批处理密文关系运算小于
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComLTEx 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = bt[0 : 16*nCount] //取出密态计算的结果密文
	}
	return retEncStr, err
}

// 批处理密态计算关系运算小于等于
func PComLTEEx(nCount uint, encData1 []byte, uiKeyIdx1 []uint, encData2 []byte, uiKeyIdx2 []uint, uiKeyIdx3 []uint) ([]byte, error) {
	var err error        // 出错返回值
	var retEncStr []byte // 功能返回值

	encDataByte1 := GetBytePointer(encData1) // 将go字符串转换C字符串
	encDataByte2 := GetBytePointer(encData2) // 将go字符串转换C字符串
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex2Tmp := GetintPointerint64(uiKeyIdx2)
	keyIndex3Tmp := GetintPointerint64(uiKeyIdx3)
	bt := make([]byte, 16*nCount)                                                                                      // 给密态计算的密文赋初值
	encResult := GetBytePointer(bt)                                                                                    // 将字节转换为字符串
	rv := C.PComLTEEx(C.uint(nCount), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, encResult, keyIndex3Tmp) //批处理密文关系运算小于
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComLTEEx 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = bt[0 : 16*nCount] //取出密态计算的结果密文
	}
	return retEncStr, err
}

// 批处理密态计算关系运算大于
func PComGTEx(nCount uint, encData1 []byte, uiKeyIdx1 []uint, encData2 []byte, uiKeyIdx2 []uint, uiKeyIdx3 []uint) ([]byte, error) {
	var err error        // 出错返回值
	var retEncStr []byte // 功能返回值

	encDataByte1 := GetBytePointer(encData1) // 将go字符串转换C字符串
	encDataByte2 := GetBytePointer(encData2) // 将go字符串转换C字符串
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex2Tmp := GetintPointerint64(uiKeyIdx2)
	keyIndex3Tmp := GetintPointerint64(uiKeyIdx3)
	bt := make([]byte, 16*nCount)                                                                                     // 给密态计算的密文赋初值
	encResult := GetBytePointer(bt)                                                                                   // 将字节转换为字符串
	rv := C.PComGTEx(C.uint(nCount), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, encResult, keyIndex3Tmp) //批处理密文关系运算大于
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComGTEx 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = bt[0 : 16*nCount] //取出密态计算的结果密文
	}
	return retEncStr, err
}

// 批处理密态计算关系运算大于等于
func PComGTEEx(nCount uint, encData1 []byte, uiKeyIdx1 []uint, encData2 []byte, uiKeyIdx2 []uint, uiKeyIdx3 []uint) ([]byte, error) {
	var err error        // 出错返回值
	var retEncStr []byte // 功能返回值

	encDataByte1 := GetBytePointer(encData1) // 将go字符串转换C字符串
	encDataByte2 := GetBytePointer(encData2) // 将go字符串转换C字符串
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex2Tmp := GetintPointerint64(uiKeyIdx2)
	keyIndex3Tmp := GetintPointerint64(uiKeyIdx3)
	bt := make([]byte, 16*nCount)                                                                                      // 给密态计算的密文赋初值
	encResult := GetBytePointer(bt)                                                                                    // 将字节转换为字符串
	rv := C.PComGTEEx(C.uint(nCount), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, encResult, keyIndex3Tmp) //批处理密文关系运算大于等于
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComGTEEx 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = bt[0 : 16*nCount] //取出密态计算的结果密文
	}
	return retEncStr, err
}

// 批处理密态计算关系运算等于
func PComEQEx(nCount uint, encData1 []byte, uiKeyIdx1 []uint, encData2 []byte, uiKeyIdx2 []uint, uiKeyIdx3 []uint) ([]byte, error) {
	var err error        // 出错返回值
	var retEncStr []byte // 功能返回值

	encDataByte1 := GetBytePointer(encData1) // 将go字符串转换C字符串
	encDataByte2 := GetBytePointer(encData2) // 将go字符串转换C字符串
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex2Tmp := GetintPointerint64(uiKeyIdx2)
	keyIndex3Tmp := GetintPointerint64(uiKeyIdx3)
	bt := make([]byte, 16*nCount)                                                                                     // 给密态计算的密文赋初值
	encResult := GetBytePointer(bt)                                                                                   // 将字节转换为字符串
	rv := C.PComEQEx(C.uint(nCount), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, encResult, keyIndex3Tmp) //批处理密文关系运算等于
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComEQEx 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = bt[0 : 16*nCount] //取出密态计算的结果密文
	}
	return retEncStr, err
}

// 批处理密态计算关系运算不等于
func PComNEEx(nCount uint, encData1 []byte, uiKeyIdx1 []uint, encData2 []byte, uiKeyIdx2 []uint, uiKeyIdx3 []uint) ([]byte, error) {

	var err error        // 出错返回值
	var retEncStr []byte // 功能返回值

	encDataByte1 := GetBytePointer(encData1) // 将go字符串转换C字符串
	encDataByte2 := GetBytePointer(encData2) // 将go字符串转换C字符串
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex2Tmp := GetintPointerint64(uiKeyIdx2)
	keyIndex3Tmp := GetintPointerint64(uiKeyIdx3)
	bt := make([]byte, 16*nCount)                                                                                     // 给密态计算的密文赋初值
	encResult := GetBytePointer(bt)                                                                                   // 将字节转换为字符串
	rv := C.PComNEEx(C.uint(nCount), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, encResult, keyIndex3Tmp) //批处理密文关系运算不等于
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComNEEx 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = bt[0 : 16*nCount] //取出密态计算的结果密文
	}
	return retEncStr, err
}

// -------------------批处理-----------------密态计算逻辑运算与、或、非 3个接口
// 批处理逻辑运算与 AND
func PLogAndEx(nCount uint, encData1 []byte, uiKeyIdx1 []uint, encData2 []byte, uiKeyIdx2 []uint, uiKeyIdx3 []uint) ([]byte, error) {
	var err error // 出错返回值
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1) // 将go字符串转换C字符串
	encDataByte2 := GetBytePointer(encData2) // 将go字符串转换C字符串
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex2Tmp := GetintPointerint64(uiKeyIdx2)
	keyIndex3Tmp := GetintPointerint64(uiKeyIdx3)
	encResult := make([]byte, 16*nCount)                                                                                  // 给密态计算的密文赋初值
	encResultPtr := GetBytePointer(encResult)                                                                             // 将字节转换为字符串
	rv := C.PLogAndEx(C.uint(nCount), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, encResultPtr, keyIndex3Tmp) //密文logic AND
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PLogAndEx 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = encResult[0 : 16*nCount] //取出密态计算的结果密文
	}
	return retEncStr, err
}

// 批处理逻辑运算或 Or
func PLogOrEx(nCount uint, encData1 []byte, uiKeyIdx1 []uint, encData2 []byte, uiKeyIdx2 []uint, uiKeyIdx3 []uint) ([]byte, error) {
	var err error // 出错返回值
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1) // 将go字符串转换C字符串
	encDataByte2 := GetBytePointer(encData2) // 将go字符串转换C字符串
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex2Tmp := GetintPointerint64(uiKeyIdx2)
	keyIndex3Tmp := GetintPointerint64(uiKeyIdx3)
	encResult := make([]byte, 16*nCount)                                                                                 // 给密态计算的密文赋初值
	encResultPtr := GetBytePointer(encResult)                                                                            // 将字节转换为字符串
	rv := C.PLogOrEx(C.uint(nCount), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, encResultPtr, keyIndex3Tmp) //密文logic OR
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PLogOrEx 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = encResult[0 : 16*nCount] //取出密态计算的结果密文
	}
	return retEncStr, err
}

// 批处理逻辑运算非 Not
func PLogNotEx(nCount uint, encData1 []byte, uiKeyIdx1 []uint, uiKeyIdx3 []uint) ([]byte, error) {
	var err error // 出错返回值
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1) // 将go字符串转换C字符串
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex3Tmp := GetintPointerint64(uiKeyIdx3)
	encResult := make([]byte, 16*nCount)                                                      // 给密态计算的密文赋初值
	encResultPtr := GetBytePointer(encResult)                                                 // 将字节转换为字符串
	rv := C.PLogNotEx(C.uint(nCount), encDataByte1, keyIndex1Tmp, encResultPtr, keyIndex3Tmp) //密文logic NOT
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PLogNotEx 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = encResult[0 : 16*nCount] //取出密态计算的结果密文
	}
	return retEncStr, err
}

// ------------------批处理直接返回明文真假值--------------密态计算关系运算<、<=、>、>=、==、<> 6个接口
// 批处理密态计算关系运算小于返回明文真假值
func PComLTExp(nCount uint, encData1 []byte, uiKeyIdx1 []uint, encData2 []byte, uiKeyIdx2 []uint) ([]int32, error) {
	var err error // 出错返回值
	var retPlainData []int32
	encDataByte1 := GetBytePointer(encData1) // 将go字符串转换C字符串
	encDataByte2 := GetBytePointer(encData2) // 将go字符串转换C字符串
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex2Tmp := GetintPointerint64(uiKeyIdx2)
	retPlainData = make([]int32, nCount) // 给密态计算的密文赋初值
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData[0]))
	rv := C.PComLTExp(C.uint(nCount), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, retPlainData1) // 密文小于返回明文结果
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComLTExp 密态计算时出错！错误号：" + cw)
	}
	return retPlainData, err
}

// 批处理密态计算关系运算小于等于返回明文真假值
func PComLTEExp(nCount uint, encData1 []byte, uiKeyIdx1 []uint, encData2 []byte, uiKeyIdx2 []uint) ([]int32, error) {
	var err error // 出错返回值
	var retPlainData []int32
	encDataByte1 := GetBytePointer(encData1) // 将go字符串转换C字符串
	encDataByte2 := GetBytePointer(encData2) // 将go字符串转换C字符串
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex2Tmp := GetintPointerint64(uiKeyIdx2)
	retPlainData = make([]int32, nCount) // 给密态计算的密文赋初值
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData[0]))
	rv := C.PComLTEExp(C.uint(nCount), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, retPlainData1) // 密文小于等于返回明文结果
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComLTEExp 密态计算时出错！错误号：" + cw)
	}
	return retPlainData, err
}

// 批处理密态计算关系运算大于返回明文真假值
func PComGTExp(nCount uint, encData1 []byte, uiKeyIdx1 []uint, encData2 []byte, uiKeyIdx2 []uint) ([]int32, error) {
	var err error // 出错返回值
	var retPlainData []int32
	encDataByte1 := GetBytePointer(encData1) // 将go字符串转换C字符串
	encDataByte2 := GetBytePointer(encData2) // 将go字符串转换C字符串
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex2Tmp := GetintPointerint64(uiKeyIdx2)
	retPlainData = make([]int32, nCount) // 给密态计算的密文赋初值
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData[0]))
	rv := C.PComGTExp(C.uint(nCount), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, retPlainData1) // 密文大于返回明文结果
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComGTExp 密态计算时出错！错误号：" + cw)
	}
	return retPlainData, err
}

// 批处理密态计算关系运算大于等于返回明文真假值
func PComGTEExp(nCount uint, encData1 []byte, uiKeyIdx1 []uint, encData2 []byte, uiKeyIdx2 []uint) ([]int32, error) {
	var err error // 出错返回值
	var retPlainData []int32
	encDataByte1 := GetBytePointer(encData1) // 将go字符串转换C字符串
	encDataByte2 := GetBytePointer(encData2) // 将go字符串转换C字符串
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex2Tmp := GetintPointerint64(uiKeyIdx2)
	retPlainData = make([]int32, nCount) // 给密态计算的密文赋初值
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData[0]))
	rv := C.PComGTEExp(C.uint(nCount), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, retPlainData1) // 密文大于等于返回明文结果
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComGTEExp 密态计算时出错！错误号：" + cw)
	}
	return retPlainData, err
}

// 批处理密态计算关系运算等于返回明文真假值
func PComEQExp(nCount uint, encData1 []byte, uiKeyIdx1 []uint, encData2 []byte, uiKeyIdx2 []uint) ([]int32, error) {
	var err error // 出错返回值
	var retPlainData []int32
	encDataByte1 := GetBytePointer(encData1) // 将go字符串转换C字符串
	encDataByte2 := GetBytePointer(encData2) // 将go字符串转换C字符串
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex2Tmp := GetintPointerint64(uiKeyIdx2)
	retPlainData = make([]int32, nCount) // 给密态计算的密文赋初值
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData[0]))
	rv := C.PComEQExp(C.uint(nCount), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, retPlainData1) // 密文等于返回明文结果
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComEQExp 密态计算时出错！错误号：" + cw)
	}
	return retPlainData, err
}

// 批处理密态计算关系运算不等于返回明文真假值
func PComNEExp(nCount uint, encData1 []byte, uiKeyIdx1 []uint, encData2 []byte, uiKeyIdx2 []uint) ([]int32, error) {
	var err error // 出错返回值
	var retPlainData []int32
	encDataByte1 := GetBytePointer(encData1) // 将go字符串转换C字符串
	encDataByte2 := GetBytePointer(encData2) // 将go字符串转换C字符串
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex2Tmp := GetintPointerint64(uiKeyIdx2)
	retPlainData = make([]int32, nCount) // 给密态计算的密文赋初值
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData[0]))
	rv := C.PComNEExp(C.uint(nCount), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, retPlainData1) // 密文不等于返回明文结果
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComNEExp 密态计算时出错！错误号：" + cw)
	}
	return retPlainData, err
}

// -----------------------------------------加密接口 6个接口, 对应的解密接口6个
// PEnc32 32位无符号加密
func PEnc32(uiKeyIndex uint, plainData uint32) ([]byte, error) {
	var err error                                                  // 出错返回值
	var retEncDataByte []byte                                      // 功能返回值
	bt := make([]byte, 16)                                         // 初始化34个字节
	encData := GetBytePointer(bt)                                  // 将cgo的字节转换为c语言的字节类型
	rv := C.PEnc32(C.uint(plainData), C.uint(uiKeyIndex), encData) // 加密
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PEnc32 加密时出错！错误号：" + cw)
	} else {
		retEncDataByte = bt[0:16] // 取出密文
	}
	return retEncDataByte, err
}

// PEncS32 32位有符号加密
func PEncS32(uiKeyIndex uint, plainData int32) ([]byte, error) {
	var err error                                                  // 出错返回值
	var retEncDataByte []byte                                      // 功能返回值
	bt := make([]byte, 16)                                         // 初始化34个字节
	encData := GetBytePointer(bt)                                  // 将cgo的字节转换为c语言的字节类型
	rv := C.PEncS32(C.int(plainData), C.uint(uiKeyIndex), encData) // 加密
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PEncS32 密态计算时出错！错误号：" + cw)
	} else {
		retEncDataByte = bt[0:16] // 取出密文
	}
	return retEncDataByte, err
}

// PEncS64 64位有符号加密
func PEncS64(uiKeyIndex uint, plainData int64) ([]byte, error) {
	var err error                                                       // 出错返回值
	var retEncDataByte []byte                                           // 功能返回值
	bt := make([]byte, 16)                                              // 初始化34个字节
	encData := GetBytePointer(bt)                                       // 将cgo的字节转换为c语言的字节类型
	rv := C.PEncS64(C.longlong(plainData), C.uint(uiKeyIndex), encData) // 加密
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PEncS64 密态计算时出错！错误号：" + cw)
	} else {
		retEncDataByte = bt[0:16] // 取出密文
	}
	return retEncDataByte, err
}

// PEnc64 64位无符号加密
func PEnc64(uiKeyIndex uint, plainData uint64) ([]byte, error) {
	var err error                                                       // 出错返回值
	var retEncDataByte []byte                                           // 功能返回值
	bt := make([]byte, 16)                                              // 初始化34个字节
	encData := GetBytePointer(bt)                                       // 将cgo的字节转换为c语言的字节类型
	rv := C.PEnc64(C.ulonglong(plainData), C.uint(uiKeyIndex), encData) // 加密
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PEnc64 密态计算时出错！错误号：" + cw)
	} else {
		retEncDataByte = bt[0:16] // 取出密文
	}
	return retEncDataByte, err
}

// PEncF32 32位浮点数加密
func PEncF32(uiKeyIndex uint, plainData float32) ([]byte, error) {
	var err error                                                    // 出错返回值
	var retEncDataByte []byte                                        // 功能返回值
	bt := make([]byte, 16)                                           // 初始化34个字节
	encData := GetBytePointer(bt)                                    // 将cgo的字节转换为c语言的字节类型
	rv := C.PEncF32(C.float(plainData), C.uint(uiKeyIndex), encData) // 加密
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PEncF32 密态计算时出错！错误号：" + cw)
	} else {
		retEncDataByte = bt[0:16] // 取出密文
	}
	return retEncDataByte, err
}

// PEncF64 64位浮点数加密
func PEncF64(uiKeyIndex uint, plainData float64) ([]byte, error) {
	var err error                                                     // 出错返回值
	var retEncDataByte []byte                                         // 功能返回值
	bt := make([]byte, 16)                                            // 初始化34个字节
	encData := GetBytePointer(bt)                                     // 将cgo的字节转换为c语言的字节类型
	rv := C.PEncF64(C.double(plainData), C.uint(uiKeyIndex), encData) // 加密
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PEncF64 密态计算时出错！错误号：" + cw)
	} else {
		retEncDataByte = bt[0:16] // 取出密文
	}
	return retEncDataByte, err
}

// PDecS32 32位有符号解密
func PDecS32(pEncrypteddata []byte, uiKeyIndex uint, user_auth_pass_word string) (int32, error) {
	var err error          // 出错返回值
	var retPlainData int32 // 功能返回值
	pEncrypteddata1 := GetBytePointer(pEncrypteddata)
	user_auth_pass_word_str := C.CString(user_auth_pass_word)                         // 将go字符串转换C字符串
	defer C.free(unsafe.Pointer(user_auth_pass_word_str))                             // 动态回收内存空间
	var user_auth_pass_word_str1 = (*C.char)(unsafe.Pointer(user_auth_pass_word_str)) // 将C字符串转换C.char指针
	var ncount int32
	PainData := (*C.int)(unsafe.Pointer(&ncount))                                            // 将cgo的字节转换为c语言的uint类型
	rv := C.PDecS32(pEncrypteddata1, C.uint(uiKeyIndex), user_auth_pass_word_str1, PainData) // 解密
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PDecS32 密态计算时出错！错误号：" + cw)
	} else {
		retPlainData = int32(*PainData)
	}
	return retPlainData, err
}

// PDec32 32位无符号解密
func PDec32(pEncrypteddata []byte, uiKeyIndex uint, user_auth_pass_word string) (uint32, error) {
	var err error           // 出错返回值
	var retPlainData uint32 // 功能返回值
	pEncrypteddata1 := GetBytePointer(pEncrypteddata)
	user_auth_pass_word_str := C.CString(user_auth_pass_word)                         // 将go字符串转换C字符串
	defer C.free(unsafe.Pointer(user_auth_pass_word_str))                             // 动态回收内存空间
	var user_auth_pass_word_str1 = (*C.char)(unsafe.Pointer(user_auth_pass_word_str)) // 将C字符串转换C.char指针
	var ncount uint
	PainData := (*C.uint)(unsafe.Pointer(&ncount))                                          // 将cgo的字节转换为c语言的uint类型
	rv := C.PDec32(pEncrypteddata1, C.uint(uiKeyIndex), user_auth_pass_word_str1, PainData) // 解密
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PDecS32 密态计算时出错！错误号：" + cw)
	} else {
		retPlainData = uint32(*PainData)
	}
	return retPlainData, err
}

// PDecS64 64位有符号解密
func PDecS64(pEncrypteddata []byte, uiKeyIndex uint, user_auth_pass_word string) (int64, error) {
	var err error          // 出错返回值
	var retPlainData int64 // 功能返回值
	pEncrypteddata1 := GetBytePointer(pEncrypteddata)
	user_auth_pass_word_str := C.CString(user_auth_pass_word)                         // 将go字符串转换C字符串
	defer C.free(unsafe.Pointer(user_auth_pass_word_str))                             // 动态回收内存空间
	var user_auth_pass_word_str1 = (*C.char)(unsafe.Pointer(user_auth_pass_word_str)) // 将C字符串转换C.char指针
	var ncount int64
	PainData := (*C.longlong)(unsafe.Pointer(&ncount))                                       // 将cgo的字节转换为c语言的uint类型
	rv := C.PDecS64(pEncrypteddata1, C.uint(uiKeyIndex), user_auth_pass_word_str1, PainData) // 解密
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PDecS64 密态计算时出错！错误号：" + cw)
	} else {
		retPlainData = int64(*PainData)
	}
	return retPlainData, err
}

// PDec64 64位无符号解密
func PDec64(pEncrypteddata []byte, uiKeyIndex uint, user_auth_pass_word string) (uint64, error) {
	var err error           // 出错返回值
	var retPlainData uint64 // 功能返回值
	pEncrypteddata1 := GetBytePointer(pEncrypteddata)
	user_auth_pass_word_str := C.CString(user_auth_pass_word)                         // 将go字符串转换C字符串
	defer C.free(unsafe.Pointer(user_auth_pass_word_str))                             // 动态回收内存空间
	var user_auth_pass_word_str1 = (*C.char)(unsafe.Pointer(user_auth_pass_word_str)) // 将C字符串转换C.char指针
	var ncount uint64
	PainData := (*C.ulonglong)(unsafe.Pointer(&ncount))                                     // 将cgo的字节转换为c语言的uint类型
	rv := C.PDec64(pEncrypteddata1, C.uint(uiKeyIndex), user_auth_pass_word_str1, PainData) // 解密
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PDec64 密态计算时出错！错误号：" + cw)
	} else {
		retPlainData = uint64(*PainData)
	}
	return retPlainData, err
}

// PDecF32 32位浮点数解密
func PDecF32(pEncrypteddata []byte, uiKeyIndex uint, user_auth_pass_word string) (float32, error) {
	var err error            // 出错返回值
	var retPlainData float32 // 功能返回值
	pEncrypteddata1 := GetBytePointer(pEncrypteddata)
	user_auth_pass_word_str := C.CString(user_auth_pass_word)                         // 将go字符串转换C字符串
	defer C.free(unsafe.Pointer(user_auth_pass_word_str))                             // 动态回收内存空间
	var user_auth_pass_word_str1 = (*C.char)(unsafe.Pointer(user_auth_pass_word_str)) // 将C字符串转换C.char指针
	var ncount float32
	PainData := (*C.float)(unsafe.Pointer(&ncount))                                          // 将cgo的字节转换为c语言的uint类型
	rv := C.PDecF32(pEncrypteddata1, C.uint(uiKeyIndex), user_auth_pass_word_str1, PainData) // 解密
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PDecF32 密态计算时出错！错误号：" + cw)
	} else {
		retPlainData = float32(*PainData)
	}
	return retPlainData, err
}

// PDecF64 64位浮点数解密
func PDecF64(pEncrypteddata []byte, uiKeyIndex uint, user_auth_pass_word string) (float64, error) {
	var err error            // 出错返回值
	var retPlainData float64 // 功能返回值
	pEncrypteddata1 := GetBytePointer(pEncrypteddata)
	user_auth_pass_word_str := C.CString(user_auth_pass_word)                         // 将go字符串转换C字符串
	defer C.free(unsafe.Pointer(user_auth_pass_word_str))                             // 动态回收内存空间
	var user_auth_pass_word_str1 = (*C.char)(unsafe.Pointer(user_auth_pass_word_str)) // 将C字符串转换C.char指针
	var ncount float64
	PainData := (*C.double)(unsafe.Pointer(&ncount))                                         // 将cgo的字节转换为c语言的uint类型
	rv := C.PDecF64(pEncrypteddata1, C.uint(uiKeyIndex), user_auth_pass_word_str1, PainData) // 解密
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PDecF64 密态计算时出错！错误号：" + cw)
	} else {
		retPlainData = float64(*PainData)
	}
	return retPlainData, err
}

// 字符串加密
func PEncStr(plainDataStr string, uiKeyIndex uint) ([]byte, error) {
	var err error
	var retEncByte []byte
	var plainDataStrLen int
	sourceStr := C.CString(plainDataStr)                         // 将go字符串转换C字符串
	defer C.free(unsafe.Pointer(sourceStr))                      // 动态回收内存空间
	var sourceStr1 = (*C.char)(unsafe.Pointer(sourceStr))        // 将C字符串转换C.char指针
	plainDataStrLen = int(C.getEncStrLenFromPlainStr(sourceStr)) // 计算明文加密时需要的长度
	bt := make([]byte, plainDataStrLen)                          // 初始化34个字节
	encDataByte := GetBytePointer(bt)                            // 将cgo的字节转换为c语言的字节类型
	rv := C.PEncStr(sourceStr1, C.uint(uiKeyIndex), encDataByte) // 字符串加密 //
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PEncStr 密态计算时出错！错误号：" + cw)
	} else {
		retEncByte = bt[0:plainDataStrLen] // 取出加密结果
	}
	return retEncByte, err
}

// 字符串解密
func PDecStr(pEncrypteddata []byte, uiKeyIndex uint, user_auth_pass_word string) (string, error) {
	var err error
	var retplainDataPtr string

	pEncrypteddata1 := GetBytePointer(pEncrypteddata)

	user_auth_pass_word_str := C.CString(user_auth_pass_word)                         // 将go字符串转换C字符串
	defer C.free(unsafe.Pointer(user_auth_pass_word_str))                             // 动态回收内存空间
	var user_auth_pass_word_str1 = (*C.char)(unsafe.Pointer(user_auth_pass_word_str)) // 将C字符串转换C.char指针
	plainDataStrLen := len(pEncrypteddata)
	plainData := make([]byte, plainDataStrLen)
	var plainDataPtr = GetCharPointer(plainData) // 将C字符串转换C.char指针
	rv := C.PDecStr(pEncrypteddata1, C.uint(uiKeyIndex), user_auth_pass_word_str1, plainDataPtr)
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PDecStr 密态计算时出错！错误号：" + cw)
	} else {
		retplainDataPtr = string(plainData) // 取出解密结果
	}
	return retplainDataPtr, err
}

// 字符串密文关系运算
// 字符串小于比较运算
func PComStrLT(encData1 []byte, uiKeyIndex1 uint64, encData2 []byte, uiKeyIndex2 uint64, uiKeyIndex3 uint64) ([]byte, error) {
	var err error // 出错返回值
	var retEncDataByte []byte
	encDatabyte1 := GetBytePointer(encData1)
	encDatabyte2 := GetBytePointer(encData2)
	EncDataStr := make([]byte, 16)
	EncDataByte1 := GetBytePointer(EncDataStr)                                                                                 // 将C字符串转换C.char指针
	rv := C.PComStrLT(encDatabyte1, C.uint(uiKeyIndex1), encDatabyte2, C.uint(uiKeyIndex2), EncDataByte1, C.uint(uiKeyIndex3)) // 密文
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComStrLT 密态计算时出错！错误号：" + cw)
	} else {
		retEncDataByte = EncDataStr[0:16] //取出密态计算的结果密文
	}
	return retEncDataByte, err
}

// 字符串小于等于比较运算
func PComStrLTE(encData1 []byte, uiKeyIndex1 uint64, encData2 []byte, uiKeyIndex2 uint64, uiKeyIndex3 uint64) ([]byte, error) {
	var err error // 出错返回值
	var retEncDataByte []byte
	encDatabyte1 := GetBytePointer(encData1)
	encDatabyte2 := GetBytePointer(encData2)
	EncDataStr := make([]byte, 16)
	EncDataByte1 := GetBytePointer(EncDataStr)                                                                                  // 将C字符串转换C.char指针
	rv := C.PComStrLTE(encDatabyte1, C.uint(uiKeyIndex1), encDatabyte2, C.uint(uiKeyIndex2), EncDataByte1, C.uint(uiKeyIndex3)) // 密文
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComStrLTE 密态计算时出错！错误号：" + cw)
	} else {
		retEncDataByte = EncDataStr[0:16] //取出密态计算的结果密文
	}
	return retEncDataByte, err
}

// 字符串大于比较运算
func PComStrGT(encData1 []byte, uiKeyIndex1 uint64, encData2 []byte, uiKeyIndex2 uint64, uiKeyIndex3 uint64) ([]byte, error) {
	var err error // 出错返回值
	var retEncDataByte []byte
	encDatabyte1 := GetBytePointer(encData1)
	encDatabyte2 := GetBytePointer(encData2)
	EncDataStr := make([]byte, 16)
	EncDataByte1 := GetBytePointer(EncDataStr)                                                                                 // 将C字符串转换C.char指针
	rv := C.PComStrGT(encDatabyte1, C.uint(uiKeyIndex1), encDatabyte2, C.uint(uiKeyIndex2), EncDataByte1, C.uint(uiKeyIndex3)) // 密文
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComStrGT 密态计算时出错！错误号：" + cw)
	} else {
		retEncDataByte = EncDataStr[0:16] //取出密态计算的结果密文
	}
	return retEncDataByte, err
}

// 字符串大于等于比较运算
func PComStrGTE(encData1 []byte, uiKeyIndex1 uint64, encData2 []byte, uiKeyIndex2 uint64, uiKeyIndex3 uint64) ([]byte, error) {
	var err error // 出错返回值
	var retEncDataByte []byte
	encDatabyte1 := GetBytePointer(encData1)
	encDatabyte2 := GetBytePointer(encData2)
	EncDataStr := make([]byte, 16)
	EncDataByte1 := GetBytePointer(EncDataStr)                                                                                  // 将C字符串转换C.char指针
	rv := C.PComStrGTE(encDatabyte1, C.uint(uiKeyIndex1), encDatabyte2, C.uint(uiKeyIndex2), EncDataByte1, C.uint(uiKeyIndex3)) // 密文
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComStrGTE 密态计算时出错！错误号：" + cw)
	} else {
		retEncDataByte = EncDataStr[0:16] //取出密态计算的结果密文
	}
	return retEncDataByte, err
}

// 字符串等于比较运算
func PComStrEQ(encData1 []byte, uiKeyIndex1 uint64, encData2 []byte, uiKeyIndex2 uint64, uiKeyIndex3 uint64) ([]byte, error) {
	var err error // 出错返回值
	var retEncDataByte []byte
	encDatabyte1 := GetBytePointer(encData1)
	encDatabyte2 := GetBytePointer(encData2)
	EncDataStr := make([]byte, 16)
	EncDataByte1 := GetBytePointer(EncDataStr)                                                                                 // 将C字符串转换C.char指针
	rv := C.PComStrEQ(encDatabyte1, C.uint(uiKeyIndex1), encDatabyte2, C.uint(uiKeyIndex2), EncDataByte1, C.uint(uiKeyIndex3)) // 密文
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComStrEQ 密态计算时出错！错误号：" + cw)
	} else {
		retEncDataByte = EncDataStr[0:16] //取出密态计算的结果密文
	}
	return retEncDataByte, err
}

// 字符串不等于比较运算
func PComStrNE(encData1 []byte, uiKeyIndex1 uint64, encData2 []byte, uiKeyIndex2 uint64, uiKeyIndex3 uint64) ([]byte, error) {
	var err error // 出错返回值
	var retEncDataByte []byte
	encDatabyte1 := GetBytePointer(encData1)
	encDatabyte2 := GetBytePointer(encData2)
	EncDataStr := make([]byte, 16)
	EncDataByte1 := GetBytePointer(EncDataStr)                                                                                 // 将C字符串转换C.char指针
	rv := C.PComStrNE(encDatabyte1, C.uint(uiKeyIndex1), encDatabyte2, C.uint(uiKeyIndex2), EncDataByte1, C.uint(uiKeyIndex3)) // 密文
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComStrNE 密态计算时出错！错误号：" + cw)
	} else {
		retEncDataByte = EncDataStr[0:16] //取出密态计算的结果密文
	}
	return retEncDataByte, err
}

// 字符串关系运算并且直接返回明文结果
// 字符串小于比较运算
func PComStrLTp(encData1 []byte, uiKeyIndex1 uint64, encData2 []byte, uiKeyIndex2 uint64) (int, error) {
	var err error // 出错返回值
	var retPlainData int
	encDatabyte1 := GetBytePointer(encData1)
	encDatabyte2 := GetBytePointer(encData2)
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData))
	rv := C.PComStrLTp(encDatabyte1, C.uint(uiKeyIndex1), encDatabyte2, C.uint(uiKeyIndex2), retPlainData1) // 密文小于返回明文结果
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComStrLTp 密态计算时出错！错误号：" + cw)
	}
	return retPlainData, err
}

// 字符串小于等于比较运算
func PComStrLTEp(encData1 []byte, uiKeyIndex1 uint64, encData2 []byte, uiKeyIndex2 uint64) (int, error) {
	var err error // 出错返回值
	var retPlainData int
	encDatabyte1 := GetBytePointer(encData1)
	encDatabyte2 := GetBytePointer(encData2)
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData))
	rv := C.PComStrLTEp(encDatabyte1, C.uint(uiKeyIndex1), encDatabyte2, C.uint(uiKeyIndex2), retPlainData1) // 密文小于等于返回明文结果
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComStrLTEp 密态计算时出错！错误号：" + cw)
	}
	return retPlainData, err
}

// 字符串大于比较运算
func PComStrGTp(encData1 []byte, uiKeyIndex1 uint64, encData2 []byte, uiKeyIndex2 uint64) (int, error) {
	var err error // 出错返回值
	var retPlainData int
	encDatabyte1 := GetBytePointer(encData1)
	encDatabyte2 := GetBytePointer(encData2)
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData))
	rv := C.PComStrGTp(encDatabyte1, C.uint(uiKeyIndex1), encDatabyte2, C.uint(uiKeyIndex2), retPlainData1) // 密文等于返回明文结果
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComStrGTp 密态计算时出错！错误号：" + cw)
	}
	return retPlainData, err
}

// 字符串大于等于比较运算
func PComStrGTEp(encData1 []byte, uiKeyIndex1 uint64, encData2 []byte, uiKeyIndex2 uint64) (int, error) {
	var err error // 出错返回值
	var retPlainData int
	encDatabyte1 := GetBytePointer(encData1)
	encDatabyte2 := GetBytePointer(encData2)
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData))
	rv := C.PComStrGTEp(encDatabyte1, C.uint(uiKeyIndex1), encDatabyte2, C.uint(uiKeyIndex2), retPlainData1) // 密文大于等于返回明文结果
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComStrGTEp 密态计算时出错！错误号：" + cw)
	}
	return retPlainData, err
}

// 字符串等于比较运算
func PComStrEQp(encData1 []byte, uiKeyIndex1 uint64, encData2 []byte, uiKeyIndex2 uint64) (int, error) {
	var err error // 出错返回值
	var retPlainData int
	encDatabyte1 := GetBytePointer(encData1)
	encDatabyte2 := GetBytePointer(encData2)
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData))
	rv := C.PComStrEQp(encDatabyte1, C.uint(uiKeyIndex1), encDatabyte2, C.uint(uiKeyIndex2), retPlainData1) // 密文等于返回明文结果
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComStrEQp 密态计算时出错！错误号：" + cw)
	}
	return retPlainData, err
}

// 字符串不等于比较运算
func PComStrNEp(encData1 []byte, uiKeyIndex1 uint64, encData2 []byte, uiKeyIndex2 uint64) (int, error) {
	var err error // 出错返回值
	var retPlainData int
	encDatabyte1 := GetBytePointer(encData1)
	encDatabyte2 := GetBytePointer(encData2)
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData))
	rv := C.PComStrNEp(encDatabyte1, C.uint(uiKeyIndex1), encDatabyte2, C.uint(uiKeyIndex2), retPlainData1) // 密文不等于返回明文结果
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComStrNEp 密态计算时出错！错误号：" + cw)
	}
	return retPlainData, err
}

// ----------------------------------------------解密接口1个接口
// PDec 解密
func PDec(uiKeyIndex uint, encData []byte, fheauth string) ([]byte, int, error) {
	var err error // 出错返回值

	encDataByte := GetBytePointer(encData)
	user_auth_pass_word_str := C.CString(fheauth)                                     // 将go字符串转换C字符串
	defer C.free(unsafe.Pointer(user_auth_pass_word_str))                             // 动态回收内存空间
	var user_auth_pass_word_str1 = (*C.char)(unsafe.Pointer(user_auth_pass_word_str)) // 将C字符串转换C.char指针

	Plaindata := make([]byte, 8) // 申请返回明文空间
	PlaindataPtr := GetBytePointer(Plaindata)
	Plaindatatype := make([]byte, 1) // 申请返回明文的类型空间
	PlaindataTypePtr := GetBytePointer(Plaindatatype)
	rv := C.PDec(encDataByte, C.uint(uiKeyIndex), user_auth_pass_word_str1, PlaindataPtr, PlaindataTypePtr)
	var PlaindataByte []byte
	var Plaindatatypeint int
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PDec 密态计算时出错！错误号：" + cw)
	} else {
		PlaindataByte = Plaindata[0:8]           // 取出明文Byte
		Plaindatatypeint = int(Plaindatatype[0]) // 取出明文的类型编码
	}
	return PlaindataByte, Plaindatatypeint, err
}

// -------------------------------------------密态计算加减乘除 4个接口
// PAdd 密态计算加法
// fmt.Println(hex.EncodeToString(encData1), hex.EncodeToString(encData2), hex.EncodeToString(bt))
func PAdd(encData1 []byte, uiKeyIdx1 uint, encData2 []byte, uiKeyIdx2 uint, uiKeyIdx3 uint) ([]byte, error) {
	var err error // 出错返回值
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	encResult := make([]byte, 16)                                                                                   // 给密态计算的密文赋初值
	encResultPtr := GetBytePointer(encResult)                                                                       // 将字节转换为字符串
	rv := C.PAdd(encDataByte1, C.uint(uiKeyIdx1), encDataByte2, C.uint(uiKeyIdx2), encResultPtr, C.uint(uiKeyIdx3)) //密文加法
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PAdd 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = encResult[0:16] // 取出密文
	}
	return retEncStr, err
}

// PSub 密态计算减法
func PSub(encData1 []byte, uiKeyIdx1 uint, encData2 []byte, uiKeyIdx2 uint, uiKeyIdx3 uint) ([]byte, error) {
	var err error // 出错返回值
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	encResult := make([]byte, 16)                                                                                   // 给密态计算的密文赋初值
	encResultPtr := GetBytePointer(encResult)                                                                       // 将字节转换为字符串
	rv := C.PSub(encDataByte1, C.uint(uiKeyIdx1), encDataByte2, C.uint(uiKeyIdx2), encResultPtr, C.uint(uiKeyIdx3)) //密文减法
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PSub 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = encResult[0:16] // 取出密文
	}
	return retEncStr, err
}

// PMul 密态计算乘法
func PMul(encData1 []byte, uiKeyIdx1 uint, encData2 []byte, uiKeyIdx2 uint, uiKeyIdx3 uint) ([]byte, error) {
	var err error // 出错返回值
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	encResult := make([]byte, 16)                                                                                   // 给密态计算的密文赋初值
	encResultPtr := GetBytePointer(encResult)                                                                       // 将字节转换为字符串
	rv := C.PMul(encDataByte1, C.uint(uiKeyIdx1), encDataByte2, C.uint(uiKeyIdx2), encResultPtr, C.uint(uiKeyIdx3)) //密文乘法
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PMul 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = encResult[0:16] // 取出密文
	}
	return retEncStr, err
}

// PDiv 密态计算除法
func PDiv(encData1 []byte, uiKeyIdx1 uint, encData2 []byte, uiKeyIdx2 uint, uiKeyIdx3 uint) ([]byte, error) {
	var err error // 出错返回值
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	encResult := make([]byte, 16)                                                                                   // 给密态计算的密文赋初值
	encResultPtr := GetBytePointer(encResult)                                                                       // 将字节转换为字符串
	rv := C.PDiv(encDataByte1, C.uint(uiKeyIdx1), encDataByte2, C.uint(uiKeyIdx2), encResultPtr, C.uint(uiKeyIdx3)) //密文除法
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PDiv 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = encResult[0:16] // 取出密文
	}
	return retEncStr, err
}

// -------------------------------------------密态计算关系运算<、<=、>、>=、==、<> 6个接口
// PComLT 密态计算关系运算小于
func PComLT(encData1 []byte, uiKeyIdx1 uint, encData2 []byte, uiKeyIdx2 uint, uiKeyIdx3 uint) ([]byte, error) {
	var err error // 出错返回值
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	encResult := make([]byte, 16)                                                                                     // 给密态计算的密文赋初值
	encResultPtr := GetBytePointer(encResult)                                                                         // 将字节转换为字符串
	rv := C.PComLT(encDataByte1, C.uint(uiKeyIdx1), encDataByte2, C.uint(uiKeyIdx2), encResultPtr, C.uint(uiKeyIdx3)) //密文关系运算小于
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComLT 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = encResult[0:16] // 取出密文
	}
	return retEncStr, err
}

// PComLTE 密态计算关系运算小于等于
func PComLTE(encData1 []byte, uiKeyIdx1 uint, encData2 []byte, uiKeyIdx2 uint, uiKeyIdx3 uint) ([]byte, error) {
	var err error // 出错返回值
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	encResult := make([]byte, 16)                                                                                      // 给密态计算的密文赋初值
	encResultPtr := GetBytePointer(encResult)                                                                          // 将字节转换为字符串
	rv := C.PComLTE(encDataByte1, C.uint(uiKeyIdx1), encDataByte2, C.uint(uiKeyIdx2), encResultPtr, C.uint(uiKeyIdx3)) //密文关系运算小于等于
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComLTE 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = encResult[0:16] // 取出密文
	}
	return retEncStr, err
}

// PComGT 3密态计算关系运算大于
func PComGT(encData1 []byte, uiKeyIdx1 uint, encData2 []byte, uiKeyIdx2 uint, uiKeyIdx3 uint) ([]byte, error) {
	var err error // 出错返回值
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	encResult := make([]byte, 16)                                                                                     // 给密态计算的密文赋初值
	encResultPtr := GetBytePointer(encResult)                                                                         // 将字节转换为字符串
	rv := C.PComGT(encDataByte1, C.uint(uiKeyIdx1), encDataByte2, C.uint(uiKeyIdx2), encResultPtr, C.uint(uiKeyIdx3)) //密文关系运算大于
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComGT 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = encResult[0:16] // 取出密文
	}
	return retEncStr, err
}

// PComGTE 密态计算关系运算大于等于
func PComGTE(encData1 []byte, uiKeyIdx1 uint, encData2 []byte, uiKeyIdx2 uint, uiKeyIdx3 uint) ([]byte, error) {
	var err error // 出错返回值
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	encResult := make([]byte, 16)                                                                                      // 给密态计算的密文赋初值
	encResultPtr := GetBytePointer(encResult)                                                                          // 将字节转换为字符串
	rv := C.PComGTE(encDataByte1, C.uint(uiKeyIdx1), encDataByte2, C.uint(uiKeyIdx2), encResultPtr, C.uint(uiKeyIdx3)) //密文关系运算大于等于
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComGTE 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = encResult[0:16] // 取出密文
	}
	return retEncStr, err
}

// PComEQ 密态计算关系运算等于
func PComEQ(encData1 []byte, uiKeyIdx1 uint, encData2 []byte, uiKeyIdx2 uint, uiKeyIdx3 uint) ([]byte, error) {
	var err error // 出错返回值
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	encResult := make([]byte, 16)                                                                                     // 给密态计算的密文赋初值
	encResultPtr := GetBytePointer(encResult)                                                                         // 将字节转换为字符串
	rv := C.PComEQ(encDataByte1, C.uint(uiKeyIdx1), encDataByte2, C.uint(uiKeyIdx2), encResultPtr, C.uint(uiKeyIdx3)) //密文关系运算等于
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComEQ 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = encResult[0:16] // 取出密文
	}
	return retEncStr, err
}

// PComNE 密态计算关系运算不等于
func PComNE(encData1 []byte, uiKeyIdx1 uint, encData2 []byte, uiKeyIdx2 uint, uiKeyIdx3 uint) ([]byte, error) {
	var err error // 出错返回值
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	encResult := make([]byte, 16)                                                                                     // 给密态计算的密文赋初值
	encResultPtr := GetBytePointer(encResult)                                                                         // 将字节转换为字符串
	rv := C.PComNE(encDataByte1, C.uint(uiKeyIdx1), encDataByte2, C.uint(uiKeyIdx2), encResultPtr, C.uint(uiKeyIdx3)) //密文关系运算不等于
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComNE 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = encResult[0:16] // 取出密文
	}
	return retEncStr, err
}

// -------------------------------------------密态计算逻辑运算与、或、非 3个接口
// PLogAnd 逻辑运算与 AND
func PLogAnd(encData1 []byte, uiKeyIdx1 uint, encData2 []byte, uiKeyIdx2 uint, uiKeyIdx3 uint) ([]byte, error) {
	var err error // 出错返回值
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	encResult := make([]byte, 16)                                                                                      // 给密态计算的密文赋初值
	encResultPtr := GetBytePointer(encResult)                                                                          // 将字节转换为字符串
	rv := C.PLogAnd(encDataByte1, C.uint(uiKeyIdx1), encDataByte2, C.uint(uiKeyIdx2), encResultPtr, C.uint(uiKeyIdx3)) //密文logic AND
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PLogAnd 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = encResult[0:16] // 取出密文
	}
	return retEncStr, err
}

// PLogOr 逻辑运算或 Or
func PLogOr(encData1 []byte, uiKeyIdx1 uint, encData2 []byte, uiKeyIdx2 uint, uiKeyIdx3 uint) ([]byte, error) {
	var err error // 出错返回值
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	encResult := make([]byte, 16)                                                                                     // 给密态计算的密文赋初值
	encResultPtr := GetBytePointer(encResult)                                                                         // 将字节转换为字符串
	rv := C.PLogOr(encDataByte1, C.uint(uiKeyIdx1), encDataByte2, C.uint(uiKeyIdx2), encResultPtr, C.uint(uiKeyIdx3)) //密文logic OR
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PLogOr 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = encResult[0:16] // 取出密文
	}
	return retEncStr, err
}

// PLogNot 逻辑运算非 Not
func PLogNot(encData1 []byte, uiKeyIdx1 uint, uiKeyIdx2 uint) ([]byte, error) {
	var err error // 出错返回值
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1)
	encResult := make([]byte, 16)                                                     // 给密态计算的密文赋初值
	encResultPtr := GetBytePointer(encResult)                                         // 将字节转换为字符串
	rv := C.PLogNot(encDataByte1, C.uint(uiKeyIdx1), encResultPtr, C.uint(uiKeyIdx2)) //密文logic NOT
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PLogNot 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = encResult[0:16] // 取出密文
	}
	return retEncStr, err
}

// -----------------直接返回明文真假值-----------------密态计算关系运算<、<=、>、>=、==、<> 6个接口
// PComLTp 密态计算关系运算小于直接返回明文真假值
func PComLTp(encData1 []byte, uiKeyIdx1 uint, encData2 []byte, uiKeyIdx2 uint) (int, error) {
	var err error // 出错返回值
	var retPlainData int
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData))
	rv := C.PComLTp(encDataByte1, C.uint(uiKeyIdx1), encDataByte2, C.uint(uiKeyIdx2), retPlainData1) // 密文小于返回明文结果
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComLTp 密态计算时出错！错误号：" + cw)
	}
	return retPlainData, err
}

// PComLTEp 密态计算关系运算小于等于直接返回明文真假值
func PComLTEp(encData1 []byte, uiKeyIdx1 uint, encData2 []byte, uiKeyIdx2 uint) (int, error) {
	var err error // 出错返回值
	var retPlainData int
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData))
	rv := C.PComLTEp(encDataByte1, C.uint(uiKeyIdx1), encDataByte2, C.uint(uiKeyIdx2), retPlainData1) // 密文小于等于返回明文结果
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComLTEp 密态计算时出错！错误号：" + cw)
	}
	return retPlainData, err
}

// PComGTp 密态计算关系运算大于直接返回明文真假值
func PComGTp(encData1 []byte, uiKeyIdx1 uint, encData2 []byte, uiKeyIdx2 uint) (int, error) {
	var err error // 出错返回值
	var retPlainData int
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData))
	rv := C.PComGTp(encDataByte1, C.uint(uiKeyIdx1), encDataByte2, C.uint(uiKeyIdx2), retPlainData1) // 密文大于返回明文结果
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComGTp 密态计算时出错！错误号：" + cw)
	}
	return retPlainData, err
}

// PComGTEp 密态计算关系运算大于等于直接返回明文真假值
func PComGTEp(encData1 []byte, uiKeyIdx1 uint, encData2 []byte, uiKeyIdx2 uint) (int, error) {
	var err error // 出错返回值
	var retPlainData int
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData))
	rv := C.PComGTEp(encDataByte1, C.uint(uiKeyIdx1), encDataByte2, C.uint(uiKeyIdx2), retPlainData1) // 密文大于等于返回明文结果
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComGTEp 密态计算时出错！错误号：" + cw)
	}
	return retPlainData, err
}

// PComEQp 密态计算关系运算等于直接返回明文真假值
func PComEQp(encData1 []byte, uiKeyIdx1 uint, encData2 []byte, uiKeyIdx2 uint) (int, error) {
	var err error // 出错返回值
	var retPlainData int
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData))
	rv := C.PComEQp(encDataByte1, C.uint(uiKeyIdx1), encDataByte2, C.uint(uiKeyIdx2), retPlainData1) // 密文等于返回明文结果
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComEQp 密态计算时出错！错误号：" + cw)
	}
	return retPlainData, err
}

// PComNEp 密态计算关系运算不等于直接返回明文真假值
func PComNEp(encData1 []byte, uiKeyIdx1 uint, encData2 []byte, uiKeyIdx2 uint) (int, error) {
	var err error // 出错返回值
	var retPlainData int
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData))
	rv := C.PComNEp(encDataByte1, C.uint(uiKeyIdx1), encDataByte2, C.uint(uiKeyIdx2), retPlainData1) // 密文不等于返回明文结果
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComNEp 密态计算时出错！错误号：" + cw)
	}
	return retPlainData, err
}

//// ---------------直接返回明文真假值-----------------密态计算逻辑运算与、或、非 3个接口
//// PLogAndP 逻辑运算与 AND
//func PLogAndP(encData1 []byte, uiKeyIdx1 uint32, encData2 []byte, uiKeyIdx2 uint32, uiKeyIdx3 uint32) (uint8, error) {
//	var err error // 出错返回值
//	var retPlainData uint8
//	encDataByte1 := GetBytePointer(encData1)
//	encDataByte2 := GetBytePointer(encData2)
//	bt := make([]byte, 16)                                                                           // 给密态计算的密文赋初值
//	retPlainData := GetBytePointer(bt)                                                               // 将字节转换为字符串
//	rv := C.PLogAndP(encDataByte1, C.uint(uiKeyIdx1), encDataByte2, C.uint(uiKeyIdx2), retPlainData) // 密文计算AND返回明文结果
//	if rv != 0 {
//		cw := fmt.Sprintf("%x", rv)
//		err = errors.New("出错信息:PAdd 密态计算时出错！错误号：" + cw)
//	} else {
//		retPlainData = uint8(bt[15])
//	}
//	return retPlainData, err
//}

//// PLogOrP 逻辑运算或 Or
//func PLogOrP(encData1 string, uiKeyIdx1 uint32, encData2 string, uiKeyIdx2 uint32, uiKeyIdx3 uint32) (uint8, error) {
//	var err error // 出错返回值
//	var retPlainData uint8
//	encDataStr1 := C.CString(encData1)                         // 将go字符串转换C字符串
//	defer C.free(unsafe.Pointer(encDataStr1))                  // 动态回收内存空间
//	var encDataStr1c = (*C.uchar)(unsafe.Pointer(encDataStr1)) // 将C字符串转换C.char指针
//
//	encDataStr2 := C.CString(encData2)                                                               // 将go字符串转换C字符串
//	defer C.free(unsafe.Pointer(encDataStr2))                                                        // 动态回收内存空间
//	var encDataStr2c = (*C.uchar)(unsafe.Pointer(encDataStr2))                                       // 将C字符串转换C.char指针
//	bt := make([]byte, 34)                                                                           // 给密态计算的密文赋初值
//	retPlainData1 := GetBytePointer(bt)                                                              // 将字节转换为字符串
//	rv := C.PLogOrP(encDataStr1c, C.uint(uiKeyIdx1), encDataStr2c, C.uint(uiKeyIdx2), retPlainData1) // 密文计算OR返回明文结果
//	var PlaindataByte []byte
//	if rv != 0 {
//		cw := fmt.Sprintf("%x", rv)
//		err = errors.New("出错信息:PAdd 密态计算时出错！错误号：" + cw)
//	} else {
//		PlaindataByte, _ = hex.DecodeString(string(bt))
//		retPlainData = uint8(PlaindataByte[15])
//	}
//	return retPlainData, err
//}
//
//// PLogNotP 逻辑运算非 Not
//func PLogNotP(encData1 string, uiKeyIdx1 uint, uiKeyIdx2 uint) (uint8, error) {
//	var err error // 出错返回值
//	var retPlainData uint8
//	encDataStr1 := C.CString(encData1)                         // 将go字符串转换C字符串
//	defer C.free(unsafe.Pointer(encDataStr1))                  // 动态回收内存空间
//	var encDataStr1c = (*C.uchar)(unsafe.Pointer(encDataStr1)) // 将C字符串转换C.char指针
//
//	bt := make([]byte, 34)                                                              // 给密态计算的密文赋初值
//	retPlainData1 := GetBytePointer(bt)                                                 // 将字节转换为字符串
//	rv := C.PLogNotP(encDataStr1c, C.uint(uiKeyIdx1), C.uint(uiKeyIdx2), retPlainData1) // 密文计算NOT返回明文结果
//	var PlaindataByte []byte
//	if rv != 0 {
//		cw := fmt.Sprintf("%x", rv)
//		err = errors.New("出错信息:PAdd 密态计算时出错！错误号：" + cw)
//	} else {
//		PlaindataByte, _ = hex.DecodeString(string(bt))
//		retPlainData = uint8(PlaindataByte[15])
//	}
//	return retPlainData, err
//}

// Enc BDecimal
func PEncBDecimal(data1 string, uiKeyIndex uint) ([]byte, error) {
	var err error                                               // 出错返回值
	var retEncDataStr []byte                                    // 功能返回值
	DataStr1 := C.CString(data1)                                // 将go字符串转换C字符串
	defer C.free(unsafe.Pointer(DataStr1))                      // 动态回收内存空间
	var DataStrC = (*C.char)(unsafe.Pointer(DataStr1))          // 将C字符串转换C.char指针
	bt := make([]byte, 66)                                      // 初始化34个字节
	encData := GetBytePointer(bt)                               // 将cgo的字节转换为c语言的字节类型
	rv := C.PEncBDecimal(DataStrC, C.uint(uiKeyIndex), encData) //对明文加密
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PEncBDecimal 加密时出错！错误号：" + cw)
	} else {
		retEncDataStr = bt[0:66] // 取出密文
	}
	return retEncDataStr, err
}

func PDecBDecimal(encData []byte, uiKeyIndex uint, authCode string) (string, error) {
	var err error           // 出错返回值
	var retPlainData string // 功能返回值
	encDataByte := GetBytePointer(encData)
	user_auth_pass_word_str := C.CString(authCode)                                             // 将go字符串转换C字符串
	defer C.free(unsafe.Pointer(user_auth_pass_word_str))                                      // 动态回收内存空间
	var user_auth_pass_word_str1 = (*C.char)(unsafe.Pointer(user_auth_pass_word_str))          // 将C字符串转换C.char指针
	bt := make([]byte, 66)                                                                     // 初始化34个字节
	plainData := GetBytePointer1(bt)                                                           // 将cgo的字节转换为c语言的字节类型
	rv := C.PDecBDecimal(encDataByte, C.uint(uiKeyIndex), user_auth_pass_word_str1, plainData) // 解密
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PDecBDecimal 密态计算时出错！错误号：" + cw)
	} else {
		//retPlainData = bt[0:66]
		retPlainData = ""
		for i := 0; i < 64; i++ {
			if bt[i] != 0 {
				retPlainData += string(bt[i])
			} else {
				break
			}
		}
	}
	return retPlainData, err
}

func PAddBd(encData1 []byte, uiKeyIndex1 uint, encData2 []byte, uiKeyIndex2 uint, uiKeyIndexR uint) ([]byte, error) {
	var err error
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	bt := make([]byte, 66)
	btResult := GetBytePointer(bt)
	rv := C.PAddBd(encDataByte1, C.uint(uiKeyIndex1), encDataByte2, C.uint(uiKeyIndex2), btResult, C.uint(uiKeyIndexR))

	if rv != 0 {
		cw := fmt.Sprintf("#{rv}")
		err = errors.New("Add BDecimal Error:" + cw)
	} else {
		retEncStr = bt[0:66] // 取出密文
	}
	return retEncStr, err
}

func PSubBd(encData1 []byte, uiKeyIndex1 uint, encData2 []byte, uiKeyIndex2 uint, uiKeyIndexR uint) ([]byte, error) {
	var err error
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	bt := make([]byte, 66)
	btResult := GetBytePointer(bt)
	rv := C.PSubBd(encDataByte1, C.uint(uiKeyIndex1), encDataByte2, C.uint(uiKeyIndex2), btResult, C.uint(uiKeyIndexR))

	if rv != 0 {
		cw := fmt.Sprintf("#{rv}")
		err = errors.New("Sub BDecimal Error:" + cw)
	} else {
		retEncStr = bt[0:66] // 取出密文
	}
	return retEncStr, err
}

func PMulBd(encData1 []byte, uiKeyIndex1 uint, encData2 []byte, uiKeyIndex2 uint, uiKeyIndexR uint) ([]byte, error) {
	var err error
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	bt := make([]byte, 66)
	btResult := GetBytePointer(bt)
	rv := C.PMulBd(encDataByte1, C.uint(uiKeyIndex1), encDataByte2, C.uint(uiKeyIndex2), btResult, C.uint(uiKeyIndexR))

	if rv != 0 {
		cw := fmt.Sprintf("#{rv}")
		err = errors.New("Mul BDecimal Error:" + cw)
	} else {
		retEncStr = bt[0:66] // 取出密文
	}
	return retEncStr, err
}

func PDivBd(encData1 []byte, uiKeyIndex1 uint, encData2 []byte, uiKeyIndex2 uint, uiKeyIndexR uint) ([]byte, error) {
	var err error
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	bt := make([]byte, 66)
	btResult := GetBytePointer(bt)
	rv := C.PDivBd(encDataByte1, C.uint(uiKeyIndex1), encDataByte2, C.uint(uiKeyIndex2), btResult, C.uint(uiKeyIndexR))

	if rv != 0 {
		cw := fmt.Sprintf("#{rv}")
		err = errors.New("Div BDecimal Error:" + cw)
	} else {
		retEncStr = bt[0:66] // 取出密文
	}
	return retEncStr, err
}

// <
func PComLTBd(encData1 []byte, uiKeyIndex1 uint, encData2 []byte, uiKeyIndex2 uint, uiKeyIndexR uint) ([]byte, error) {
	var err error
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	bt := make([]byte, 66)
	btResult := GetBytePointer(bt)
	rv := C.PComLTBd(encDataByte1, C.uint(uiKeyIndex1), encDataByte2, C.uint(uiKeyIndex2), btResult, C.uint(uiKeyIndexR))

	if rv != 0 {
		cw := fmt.Sprintf("#{rv}")
		err = errors.New("PComLTBd BDecimal Error:" + cw)
	} else {
		retEncStr = bt[0:66] // 取出密文
	}
	return retEncStr, err
}

// <=
func PComLTEBd(encData1 []byte, uiKeyIndex1 uint, encData2 []byte, uiKeyIndex2 uint, uiKeyIndexR uint) ([]byte, error) {
	var err error
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	bt := make([]byte, 66)
	btResult := GetBytePointer(bt)
	rv := C.PComLTEBd(encDataByte1, C.uint(uiKeyIndex1), encDataByte2, C.uint(uiKeyIndex2), btResult, C.uint(uiKeyIndexR))

	if rv != 0 {
		cw := fmt.Sprintf("#{rv}")
		err = errors.New("PComLTEBd BDecimal Error:" + cw)
	} else {
		retEncStr = bt[0:66] // 取出密文
	}
	return retEncStr, err
}

// >
func PComGTBd(encData1 []byte, uiKeyIndex1 uint, encData2 []byte, uiKeyIndex2 uint, uiKeyIndexR uint) ([]byte, error) {
	var err error
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	bt := make([]byte, 66)
	btResult := GetBytePointer(bt)
	rv := C.PComGTBd(encDataByte1, C.uint(uiKeyIndex1), encDataByte2, C.uint(uiKeyIndex2), btResult, C.uint(uiKeyIndexR))

	if rv != 0 {
		cw := fmt.Sprintf("#{rv}")
		err = errors.New("PComGTBd BDecimal Error:" + cw)
	} else {
		retEncStr = bt[0:66] // 取出密文
	}
	return retEncStr, err
}

// >=
func PComGTEBd(encData1 []byte, uiKeyIndex1 uint, encData2 []byte, uiKeyIndex2 uint, uiKeyIndexR uint) ([]byte, error) {
	var err error
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	bt := make([]byte, 66)
	btResult := GetBytePointer(bt)
	rv := C.PComGTEBd(encDataByte1, C.uint(uiKeyIndex1), encDataByte2, C.uint(uiKeyIndex2), btResult, C.uint(uiKeyIndexR))

	if rv != 0 {
		cw := fmt.Sprintf("#{rv}")
		err = errors.New("PComGTBd BDecimal Error:" + cw)
	} else {
		retEncStr = bt[0:66] // 取出密文
	}
	return retEncStr, err
}

// ==
func PComEQBd(encData1 []byte, uiKeyIndex1 uint, encData2 []byte, uiKeyIndex2 uint, uiKeyIndexR uint) ([]byte, error) {
	var err error
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	bt := make([]byte, 66)
	btResult := GetBytePointer(bt)
	rv := C.PComEQBd(encDataByte1, C.uint(uiKeyIndex1), encDataByte2, C.uint(uiKeyIndex2), btResult, C.uint(uiKeyIndexR))

	if rv != 0 {
		cw := fmt.Sprintf("#{rv}")
		err = errors.New("PComEQBd BDecimal Error:" + cw)
	} else {
		retEncStr = bt[0:66] // 取出密文
	}
	return retEncStr, err
}

// !=
func PComNEBd(encData1 []byte, uiKeyIndex1 uint, encData2 []byte, uiKeyIndex2 uint, uiKeyIndexR uint) ([]byte, error) {
	var err error
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	bt := make([]byte, 66)
	btResult := GetBytePointer(bt)
	rv := C.PComNEBd(encDataByte1, C.uint(uiKeyIndex1), encDataByte2, C.uint(uiKeyIndex2), btResult, C.uint(uiKeyIndexR))

	if rv != 0 {
		cw := fmt.Sprintf("#{rv}")
		err = errors.New("PComNEBd BDecimal Error:" + cw)
	} else {
		retEncStr = bt[0:66] // 取出密文
	}
	return retEncStr, err
}

// < plain
func PComLTpBd(encData1 []byte, uiKeyIndex1 uint, encData2 []byte, uiKeyIndex2 uint) (int, error) {
	var err error
	var retPlainData int
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData))
	rv := C.PComLTpBd(encDataByte1, C.uint(uiKeyIndex1), encDataByte2, C.uint(uiKeyIndex2), retPlainData1)

	if rv != 0 {
		cw := fmt.Sprintf("#{rv}")
		err = errors.New("PComLTpBd BDecimal Error:" + cw)
	}
	return retPlainData, err
}

// <= plain
func PComLTEpBd(encData1 []byte, uiKeyIndex1 uint, encData2 []byte, uiKeyIndex2 uint) (int, error) {
	var err error
	var retPlainData int
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData))
	rv := C.PComLTEpBd(encDataByte1, C.uint(uiKeyIndex1), encDataByte2, C.uint(uiKeyIndex2), retPlainData1)

	if rv != 0 {
		cw := fmt.Sprintf("#{rv}")
		err = errors.New("PComLTEpBd BDecimal Error:" + cw)
	}
	return retPlainData, err
}

// > plain
func PComGTpBd(encData1 []byte, uiKeyIndex1 uint, encData2 []byte, uiKeyIndex2 uint) (int, error) {
	var err error
	var retPlainData int
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData))
	rv := C.PComGTpBd(encDataByte1, C.uint(uiKeyIndex1), encDataByte2, C.uint(uiKeyIndex2), retPlainData1)

	if rv != 0 {
		cw := fmt.Sprintf("#{rv}")
		err = errors.New("PComGTpBd BDecimal Error:" + cw)
	}
	return retPlainData, err
}

// >= plain
func PComGTEpBd(encData1 []byte, uiKeyIndex1 uint, encData2 []byte, uiKeyIndex2 uint) (int, error) {
	var err error
	var retPlainData int
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData))
	rv := C.PComGTEpBd(encDataByte1, C.uint(uiKeyIndex1), encDataByte2, C.uint(uiKeyIndex2), retPlainData1)

	if rv != 0 {
		cw := fmt.Sprintf("#{rv}")
		err = errors.New("PComGTEpBd BDecimal Error:" + cw)
	}
	return retPlainData, err
}

// == plain
func PComEQpBd(encData1 []byte, uiKeyIndex1 uint, encData2 []byte, uiKeyIndex2 uint) (int, error) {
	var err error
	var retPlainData int
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData))
	rv := C.PComEQpBd(encDataByte1, C.uint(uiKeyIndex1), encDataByte2, C.uint(uiKeyIndex2), retPlainData1)

	if rv != 0 {
		cw := fmt.Sprintf("#{rv}")
		err = errors.New("PComEQpBd BDecimal Error:" + cw)
	}
	return retPlainData, err
}

// != plain
func PComNEpBd(encData1 []byte, uiKeyIndex1 uint, encData2 []byte, uiKeyIndex2 uint) (int, error) {
	var err error
	var retPlainData int
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData))
	rv := C.PComNEpBd(encDataByte1, C.uint(uiKeyIndex1), encDataByte2, C.uint(uiKeyIndex2), retPlainData1)

	if rv != 0 {
		cw := fmt.Sprintf("#{rv}")
		err = errors.New("PComNEpBd BDecimal Error:" + cw)
	}
	return retPlainData, err
}

// ---------------------------------------------------
//func PEncBDecimalEx(count uint, plainData []string, keyIndex1 []uint) ([]byte, error) {
//	var err error
//	var ret []byte
//	i := 0
//	data1 := make([](*C.char), count)
//	for i = 0; i < int(count); i++ {
//		tmp := C.CString(plainData[i])
//		defer C.free(unsafe.Pointer(tmp))
//		data1[i] = tmp
//	}
//	data1Ptr := (**C.char)(unsafe.Pointer(&data1)) // 将C字符串转换C.char指针
//	keyIndex1Ptr := GetUintPointeruint32(keyIndex1)
//
//	bt := make([]byte, 64*count+2) // 初始化64 * nCount个字节
//	//encData := (*C.uchar)(unsafe.Pointer(&bt))
//	encData := GetBytePointer(bt)
//
//	rv := C.PEncBDecimalEx(C.uint(count), data1Ptr, keyIndex1Ptr, encData)
//	if rv != 0 {
//		cw := fmt.Sprintf("#{rv}")
//		err = errors.New("PEncBDecimalEx Error:" + cw)
//	} else {
//		ret = bt[0 : 64*count+2] // 取出密文
//	}
//	return ret, err
//}

//func PDecBDecimalEx(count uint, encData []byte, keyIndex1 []uint, authCode string) ([]string, error) {
//	var err error
//	var ret []string
//	encDataByte := GetBytePointer(encData)
//
//	user_auth_pass_word_str := C.CString(authCode)                                    // 将go字符串转换C字符串
//	defer C.free(unsafe.Pointer(user_auth_pass_word_str))                             // 动态回收内存空间
//	var user_auth_pass_word_str1 = (*C.char)(unsafe.Pointer(user_auth_pass_word_str)) // 将C字符串转换C.char指针
//
//	keyIndex1Ptr := GetUintPointeruint32(keyIndex1)
//	//result := make([]C.CH_CHARPTR, count)
//	result := make([](*C.char), count)
//	for i := 0; i < int(count); i++ {
//		item := make([]byte, 66)
//		tmp := C.CString(string(item))
//		defer C.free(unsafe.Pointer(tmp))
//		result[i] = tmp
//	}
//	result1 := (**C.char)(unsafe.Pointer(&result))
//	rv := C.PDecBDecimalEx(C.uint(count), encDataByte, keyIndex1Ptr, user_auth_pass_word_str1, result1)
//	if rv != 0 {
//		cw := fmt.Sprintf("#{rv}")
//		err = errors.New("PDecBDecimalEx Error:" + cw)
//	} else {
//		ret = make([]string, count)
//		//for i := 0; i < int(count); i++ {
//		//	ret[i] = C.GoString(result[i])
//		//}
//		return ret, nil
//	}
//	return nil, err
//}

// BigDecimal 批处理加法
func PAddBdEx(nCount uint, encData1 []byte, uiKeyIdx1 []uint, encData2 []byte, uiKeyIdx2 []uint, uiKeyIdx3 []uint) ([]byte, error) {
	var err error        // 出错返回值
	var retEncStr []byte // 功能返回值

	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex2Tmp := GetintPointerint64(uiKeyIdx2)
	keyIndex3Tmp := GetintPointerint64(uiKeyIdx3)
	bt := make([]byte, 64*nCount+2)                                                                                   // 给密态计算的密文赋初值
	encResult := GetBytePointer(bt)                                                                                   // 将字节转换为字符串
	rv := C.PAddBdEx(C.uint(nCount), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, encResult, keyIndex3Tmp) //批处理密文加法
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PAddBdEx 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = bt[0 : 64*nCount] //取出密态计算的结果密文
	}
	return retEncStr, err
}

// BigDecimal 批处理减法
func PSubBdEx(nCount uint, encData1 []byte, uiKeyIdx1 []uint, encData2 []byte, uiKeyIdx2 []uint, uiKeyIdx3 []uint) ([]byte, error) {
	var err error        // 出错返回值
	var retEncStr []byte // 功能返回值

	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex2Tmp := GetintPointerint64(uiKeyIdx2)
	keyIndex3Tmp := GetintPointerint64(uiKeyIdx3)
	bt := make([]byte, 64*nCount+2)                                                                                   // 给密态计算的密文赋初值
	encResult := GetBytePointer(bt)                                                                                   // 将字节转换为字符串
	rv := C.PSubBdEx(C.uint(nCount), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, encResult, keyIndex3Tmp) //批处理密文加法
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PSubBdEx 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = bt[0 : 64*nCount] //取出密态计算的结果密文
	}
	return retEncStr, err
}

// BigDecimal 批处理乘法
func PMulBdEx(nCount uint, encData1 []byte, uiKeyIdx1 []uint, encData2 []byte, uiKeyIdx2 []uint, uiKeyIdx3 []uint) ([]byte, error) {
	var err error        // 出错返回值
	var retEncStr []byte // 功能返回值

	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex2Tmp := GetintPointerint64(uiKeyIdx2)
	keyIndex3Tmp := GetintPointerint64(uiKeyIdx3)
	bt := make([]byte, 64*nCount+2)                                                                                   // 给密态计算的密文赋初值
	encResult := GetBytePointer(bt)                                                                                   // 将字节转换为字符串
	rv := C.PMulBdEx(C.uint(nCount), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, encResult, keyIndex3Tmp) //批处理密文加法
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PMulBdEx 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = bt[0 : 64*nCount] //取出密态计算的结果密文
	}
	return retEncStr, err
}

// BigDecimal 批处理除法
func PDivBdEx(nCount uint, encData1 []byte, uiKeyIdx1 []uint, encData2 []byte, uiKeyIdx2 []uint, uiKeyIdx3 []uint) ([]byte, error) {
	var err error        // 出错返回值
	var retEncStr []byte // 功能返回值

	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex2Tmp := GetintPointerint64(uiKeyIdx2)
	keyIndex3Tmp := GetintPointerint64(uiKeyIdx3)
	bt := make([]byte, 64*nCount+2)                                                                                   // 给密态计算的密文赋初值
	encResult := GetBytePointer(bt)                                                                                   // 将字节转换为字符串
	rv := C.PDivBdEx(C.uint(nCount), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, encResult, keyIndex3Tmp) //批处理密文加法
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PDivBdEx 密态计算时出错！错误号：" + cw)
	} else {
		retEncStr = bt[0 : 64*nCount] //取出密态计算的结果密文
	}
	return retEncStr, err
}

// BigDecimal <
func PComLTBdEx(count uint, encData1 []byte, keyIndex1 []uint, encData2 []byte, keyIndex2 []uint, resultIndex []uint) ([]byte, error) {
	var err error
	var retEncStr []byte

	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	keyIndex1Tmp := GetintPointerint64(keyIndex1)
	keyIndex2Tmp := GetintPointerint64(keyIndex2)
	keyIndex3Tmp := GetintPointerint64(resultIndex)
	bt := make([]byte, 32*count+2)
	btResult := GetBytePointer(bt)
	rv := C.PComLTBdEx(C.uint(count), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, btResult, keyIndex3Tmp)
	if rv != 0 {
		cw := fmt.Sprintf("#{rv}")
		err = errors.New("PComLTBdEx BDecimal Error:" + cw)
	} else {
		retEncStr = bt[0 : 64*count] //取出密态计算的结果密文
	}
	return retEncStr, err
}

// BigDecimal <=
func PComLTEBdEx(count uint, encData1 []byte, keyIndex1 []uint, encData2 []byte, keyIndex2 []uint, resultIndex []uint) ([]byte, error) {
	var err error
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	keyIndex1Tmp := GetintPointerint64(keyIndex1)
	keyIndex2Tmp := GetintPointerint64(keyIndex2)
	keyIndex3Tmp := GetintPointerint64(resultIndex)
	bt := make([]byte, 32*count+2)
	btResult := GetBytePointer(bt)
	rv := C.PComLTEBdEx(C.uint(count), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, btResult, keyIndex3Tmp)
	if rv != 0 {
		cw := fmt.Sprintf("#{rv}")
		err = errors.New("PComLTEBdEx BDecimal Error:" + cw)
	} else {
		retEncStr = bt[0 : 64*count] //取出密态计算的结果密文
	}
	return retEncStr, err
}

// BigDecimal >
func PComGTBdEx(count uint, encData1 []byte, keyIndex1 []uint, encData2 []byte, keyIndex2 []uint, resultIndex []uint) ([]byte, error) {
	var err error
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	keyIndex1Tmp := GetintPointerint64(keyIndex1)
	keyIndex2Tmp := GetintPointerint64(keyIndex2)
	keyIndex3Tmp := GetintPointerint64(resultIndex)
	bt := make([]byte, 32*count+2)
	btResult := GetBytePointer(bt)
	rv := C.PComGTBdEx(C.uint(count), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, btResult, keyIndex3Tmp)
	if rv != 0 {
		cw := fmt.Sprintf("#{rv}")
		err = errors.New("PComGTBdEx BDecimal Error:" + cw)
	} else {
		retEncStr = bt[0 : 64*count] //取出密态计算的结果密文
	}
	return retEncStr, err
}

// BigDecimal >=
func PComGTEBdEx(count uint, encData1 []byte, keyIndex1 []uint, encData2 []byte, keyIndex2 []uint, resultIndex []uint) ([]byte, error) {
	var err error
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	keyIndex1Tmp := GetintPointerint64(keyIndex1)
	keyIndex2Tmp := GetintPointerint64(keyIndex2)
	keyIndex3Tmp := GetintPointerint64(resultIndex)
	bt := make([]byte, 32*count+2)
	btResult := GetBytePointer(bt)
	rv := C.PComGTEBdEx(C.uint(count), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, btResult, keyIndex3Tmp)
	if rv != 0 {
		cw := fmt.Sprintf("#{rv}")
		err = errors.New("PComGTEBdEx BDecimal Error:" + cw)
	} else {
		retEncStr = bt[0 : 64*count] //取出密态计算的结果密文
	}
	return retEncStr, err
}

// BigDecimal =
func PComEQBdEx(count uint, encData1 []byte, keyIndex1 []uint, encData2 []byte, keyIndex2 []uint, resultIndex []uint) ([]byte, error) {
	var err error
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	keyIndex1Tmp := GetintPointerint64(keyIndex1)
	keyIndex2Tmp := GetintPointerint64(keyIndex2)
	keyIndex3Tmp := GetintPointerint64(resultIndex)
	bt := make([]byte, 32*count+2)
	btResult := GetBytePointer(bt)
	rv := C.PComEQBdEx(C.uint(count), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, btResult, keyIndex3Tmp)
	if rv != 0 {
		cw := fmt.Sprintf("#{rv}")
		err = errors.New("PComEQBdEx BDecimal Error:" + cw)
	} else {
		retEncStr = bt[0 : 64*count] //取出密态计算的结果密文
	}
	return retEncStr, err
}

// BigDecimal !=
func PComNEBdEx(count uint, encData1 []byte, keyIndex1 []uint, encData2 []byte, keyIndex2 []uint, resultIndex []uint) ([]byte, error) {
	var err error
	var retEncStr []byte
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	keyIndex1Tmp := GetintPointerint64(keyIndex1)
	keyIndex2Tmp := GetintPointerint64(keyIndex2)
	keyIndex3Tmp := GetintPointerint64(resultIndex)
	bt := make([]byte, 32*count+2)
	btResult := GetBytePointer(bt)
	rv := C.PComNEBdEx(C.uint(count), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, btResult, keyIndex3Tmp)
	if rv != 0 {
		cw := fmt.Sprintf("#{rv}")
		err = errors.New("PComEQBdEx BDecimal Error:" + cw)
	} else {
		retEncStr = bt[0 : 64*count] //取出密态计算的结果密文
	}
	return retEncStr, err
}

// ------------------批处理直接返回明文真假值--------------密态计算关系运算<、<=、>、>=、==、<> 6个接口
// 小于返回明文真假值
func PComLTBdExp(nCount uint, encData1 []byte, uiKeyIdx1 []uint, encData2 []byte, uiKeyIdx2 []uint) ([]int32, error) {
	var err error // 出错返回值
	var retPlainData []int32
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex2Tmp := GetintPointerint64(uiKeyIdx2)
	retPlainData = make([]int32, nCount) // 给密态计算的密文赋初值
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData[0]))
	rv := C.PComLTBdExp(C.uint(nCount), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, retPlainData1) // 密文小于返回明文结果
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComLTBdExp 密态计算时出错！错误号：" + cw)
	}
	return retPlainData, err
}

// 小于等于返回明文真假值
func PComLTEBdExp(nCount uint, encData1 []byte, uiKeyIdx1 []uint, encData2 []byte, uiKeyIdx2 []uint) ([]int32, error) {
	var err error // 出错返回值
	var retPlainData []int32
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex2Tmp := GetintPointerint64(uiKeyIdx2)
	retPlainData = make([]int32, nCount) // 给密态计算的密文赋初值
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData[0]))
	rv := C.PComLTEBdExp(C.uint(nCount), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, retPlainData1) // 密文小于返回明文结果
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComLTEBdExp 密态计算时出错！错误号：" + cw)
	}
	return retPlainData, err
}

// 大于返回明文真假值
func PComGTBdExp(nCount uint, encData1 []byte, uiKeyIdx1 []uint, encData2 []byte, uiKeyIdx2 []uint) ([]int32, error) {
	var err error // 出错返回值
	var retPlainData []int32
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex2Tmp := GetintPointerint64(uiKeyIdx2)
	retPlainData = make([]int32, nCount) // 给密态计算的密文赋初值
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData[0]))
	rv := C.PComGTBdExp(C.uint(nCount), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, retPlainData1) // 密文小于返回明文结果
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComGTBdExp 密态计算时出错！错误号：" + cw)
	}
	return retPlainData, err
}

// 大于等于返回明文真假值
func PComGTEBdExp(nCount uint, encData1 []byte, uiKeyIdx1 []uint, encData2 []byte, uiKeyIdx2 []uint) ([]int32, error) {
	var err error // 出错返回值
	var retPlainData []int32
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex2Tmp := GetintPointerint64(uiKeyIdx2)
	retPlainData = make([]int32, nCount) // 给密态计算的密文赋初值
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData[0]))
	rv := C.PComGTEBdExp(C.uint(nCount), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, retPlainData1) // 密文小于返回明文结果
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComGTEBdExp 密态计算时出错！错误号：" + cw)
	}
	return retPlainData, err
}

// 等于返回明文真假值
func PComEQBdExp(nCount uint, encData1 []byte, uiKeyIdx1 []uint, encData2 []byte, uiKeyIdx2 []uint) ([]int32, error) {
	var err error // 出错返回值
	var retPlainData []int32
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex2Tmp := GetintPointerint64(uiKeyIdx2)
	retPlainData = make([]int32, nCount) // 给密态计算的密文赋初值
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData[0]))
	rv := C.PComEQBdExp(C.uint(nCount), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, retPlainData1) // 密文小于返回明文结果
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComEQBdExp 密态计算时出错！错误号：" + cw)
	}
	return retPlainData, err
}

// 等于返回明文真假值
func PComNEBdExp(nCount uint, encData1 []byte, uiKeyIdx1 []uint, encData2 []byte, uiKeyIdx2 []uint) ([]int32, error) {
	var err error // 出错返回值
	var retPlainData []int32
	encDataByte1 := GetBytePointer(encData1)
	encDataByte2 := GetBytePointer(encData2)
	keyIndex1Tmp := GetintPointerint64(uiKeyIdx1)
	keyIndex2Tmp := GetintPointerint64(uiKeyIdx2)
	retPlainData = make([]int32, nCount) // 给密态计算的密文赋初值
	retPlainData1 := (*C.int)(unsafe.Pointer(&retPlainData[0]))
	rv := C.PComNEBdExp(C.uint(nCount), encDataByte1, keyIndex1Tmp, encDataByte2, keyIndex2Tmp, retPlainData1) // 密文小于返回明文结果
	if rv != 0 {
		cw := fmt.Sprintf("%x", rv)
		err = errors.New("出错信息:PComNEBdExp 密态计算时出错！错误号：" + cw)
	}
	return retPlainData, err
}

// 字节转换成64位无符号整数
func BytesToUint64(b []byte) uint64 {
	bytesBuffer := bytes.NewBuffer(b)
	var x uint64
	binary.Read(bytesBuffer, binary.LittleEndian, &x)
	return x
}

// 字节转换成32位无符号整数
func BytesToUint32(b []byte) uint32 {
	bytesBuffer := bytes.NewBuffer(b)
	var x uint32
	binary.Read(bytesBuffer, binary.LittleEndian, &x)
	return x
}

// 字节转换成32位有符号整数
func BytesToInt32(b []byte) int32 {
	bytesBuffer := bytes.NewBuffer(b)
	var x int32
	binary.Read(bytesBuffer, binary.LittleEndian, &x)
	return x
}

func BytesToUnt8(b []byte) uint8 {
	bytesBuffer := bytes.NewBuffer(b)
	var x uint8
	binary.Read(bytesBuffer, binary.LittleEndian, &x)
	return uint8(x)
}

// 将cgo的字节转换为c语言字符串
func GetCharPointer(val []byte) *C.char {
	return (*C.char)(unsafe.Pointer(&val[0]))
}

// 将cgo的字节转换为c语言uchar
func GetBytePointer(val []byte) *C.uchar {
	return (*C.uchar)(unsafe.Pointer(&val[0]))
}

// 将cgo的字节转换为c语言uchar
func GetBytePointer1(val []byte) *C.char {
	return (*C.char)(unsafe.Pointer(&val[0]))
}

// 将cgo的字节转换为c语言uchar
func GetuintPointer(val []uint) *C.uchar {
	return (*C.uchar)(unsafe.Pointer(&val[0]))
}

// 将cgo的字节转换为c语言uint32
func GetBytePointeruint32(val []byte) *C.uint {
	return (*C.uint)(unsafe.Pointer(&val[0]))
}

// 将cgo的字节转换为c语言int32
func GetBytePointerint32(val []byte) *C.int {
	return (*C.int)(unsafe.Pointer(&val[0]))
}

//// 将cgo的字节转换为c语言uint64
//func GetBytePointeruint64(val []byte) *C.CK_UINT64 {
//	return (*C.CK_UINT64)(unsafe.Pointer(&val[0]))
//}

//// 将cgo的字节转换为c语言int64
//func GetBytePointerint64(val []byte) *C.CK_INT64 {
//	return (*C.CK_INT64)(unsafe.Pointer(&val[0]))
//}

// 将cgo的字节转换为c语言float32
func GetBytePointerfloat32(val []byte) *C.float {
	return (*C.float)(unsafe.Pointer(&val[0]))
}

// 将cgo的字节转换为c语言float64
func GetBytePointerdouble(val []byte) *C.double {
	return (*C.double)(unsafe.Pointer(&val[0]))
}

// 将cgo的uint转换为c语言uint32
func GetUintPointeruint32(val []uint) *C.uint {
	return (*C.uint)(unsafe.Pointer(&val[0]))
}

// 将cgo的int转换为c语言int32
func GetintPointerint32(val []int32) *C.int {
	return (*C.int)(unsafe.Pointer(&val[0]))
}

// 将cgo的uint转换为c语言uint64
func GetintPointerulong64(val []uint64) *C.longlong {
	return (*C.longlong)(unsafe.Pointer(&val[0]))
}

// 将cgo的uint转换为c语言uint64
func GetintPointerint64(val []uint) *C.uint {
	return (*C.uint)(unsafe.Pointer(&val[0]))
}

// 将cgo的int转换为c语言int64
func GetuintPointeruint64(val []int64) *C.ulonglong {
	return (*C.ulonglong)(unsafe.Pointer(&val[0]))
}

// 将cgo的float转换为c语言float32
func GetfloatPointerfloat32(val []float32) *C.float {
	return (*C.float)(unsafe.Pointer(&val[0]))
}

// 将cgo的float转换为c语言double
func GetfloatPointerdouble(val []float64) *C.double {
	return (*C.double)(unsafe.Pointer(&val[0]))
}

//func GetCharArrayPointer(val []C.CK_CHAR_PTR) *C.CK_CHAR_PTR {
//	return (*C.CK_CHAR_PTR)(unsafe.Pointer(&val[0]))
//}

//func GetCharArrayPointer1(val []C.CH_CHARPTR) *C.CH_CHARPTR {
//	return (*C.CH_CHARPTR)(unsafe.Pointer(&val[0]))
//}

//func GetCharArrayPointerByChar(val unsafe.Pointer) C.CK_BYTE_PTR {
//	return (C.CK_BYTE_PTR)(val)
//}

//func GetByteArrayPointer(val []C.CK_BYTE_PTR) *C.CK_BYTE_PTR {
//	return (*C.CK_BYTE_PTR)(unsafe.Pointer(&val[0]))
//}

func ByteTrimSize(val []byte) int {
	for i := 0; i < len(val); i++ {
		if val[i] == 0 {
			return i
		}
	}
	return len(val)
}

// String to Byte right Align 16
func StringToBytes(val string) []byte {
	temp := []byte(val)
	mod := len(temp) % 16
	if mod != 0 || mod == 0 {
		for i := 0; i < 16-mod; i++ {
			temp = append(temp, 0x0)
		}
	}
	return temp

}
